#define  _CRT_SECURE_NO_WARNINGS


#include <stdio.h>

int main()
{
    int x = 0, n = 0;
    scanf("%d %d", &x, &n);
    while (n >= 7)
    {
        n -= 7;
    }
    if (n == 0)
    {
        printf("%d\n", x);
    }
    else if (n == 1)
    {
        if (x != 7)
            printf("%d\n", x + n);
        else
            printf("1");
    }
    else if (n == 2)
    {
        if (x == 6)
            printf("1\n");
        else if (x == 7)
            printf("2\n");
        else
            printf("%d\n", x + n);
    }
    else if (n == 3)
    {
        if (x == 5)
            printf("1\n");
        else if (x == 6)
            printf("2\n");
        else if (x == 7)
            printf("3\n");
        else
            printf("%d\n", x + n);
    }
    else if (n == 4)
    {
        if (x == 4)
            printf("1\n");
        else if (x == 5)
            printf("2\n");
        else if (x == 6)
            printf("3\n");
        else if (x == 7)
            printf("4\n");
        else
            printf("%d\n", x + n);
    }
    else if (n == 5)
    {
        if (x == 3)
            printf("1\n");
        else if (x == 4)
            printf("2\n");
        else if (x == 5)
            printf("3\n");
        else if (x == 6)
            printf("4\n");
        else if (x == 7)
            printf("5\n");
        else
            printf("%d\n", x + n);
    }
    else if (n == 6)
    {
        if (x == 2)
            printf("1\n");
        else if (x == 3)
            printf("2\n");
        else if (x == 4)
            printf("3\n");
        else if (x == 5)
            printf("4\n");
        else if (x == 6)
            printf("5\n");
        else if (x == 7)
            printf("6\n");
        else
            printf("%d\n", x + n);
    }

    return 0;
}